package movie.ticketing.system.view;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Enroll {
    public void enroll() {
        JFrame frameEnroll = new JFrame("注册");
        JPanel panelEnroll = new JPanel();
        frameEnroll.setSize(400, 250);
        frameEnroll.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frameEnroll.add(panelEnroll);
        panelEnroll.setLayout(null);
        frameEnroll.setLocationRelativeTo(null);// 居中显示

        JLabel userLabelEnroll = new JLabel("用户名：");
        userLabelEnroll.setBounds(20, 20, 80, 30);
        panelEnroll.add(userLabelEnroll);

        JTextField userFieldEnroll = new JTextField();
        userFieldEnroll.setBounds(100, 20, 200, 30);
        panelEnroll.add(userFieldEnroll);

        JLabel passwordEnroll = new JLabel("密码：");
        passwordEnroll.setBounds(20, 60, 80, 30);
        panelEnroll.add(passwordEnroll);

        JPasswordField passwordFieldEnroll = new JPasswordField();
        passwordFieldEnroll.setBounds(100, 60, 200, 30);
        panelEnroll.add(passwordFieldEnroll);

        JComboBox<String> comboBox = new JComboBox<>();
        comboBox.addItem("用户");
        comboBox.addItem("管理员");
        comboBox.setBounds(100, 100, 200, 30);
        panelEnroll.add(comboBox);

        JButton enrollButton = new JButton("注册");
        enrollButton.setBounds(100, 150, 100, 30);

        panelEnroll.add(enrollButton);
        JButton backButton = new JButton("返回");
        backButton.setBounds(200, 150, 100, 30);
        panelEnroll.add(backButton);
        frameEnroll.setVisible(true);

        enrollButton.addActionListener(new ActionListener() {// TODO 注册按钮
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        backButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frameEnroll.dispose();
                Login login = new Login();
                login.login();
            }
        });

    }
}
